﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Medical.Entity;
using Medical.Business;
using System.Data;

public partial class FaqInfo : WebPage
{
    /// <summary>
    /// 文章类型
    /// </summary>
    protected ArticelTypeEnum eType;

    protected int nSortID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        InitConfig();
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    /// <summary>
    /// 数据初始化
    /// </summary>
    protected void InitConfig()
    {
        if (RouteData.Values["urlname"] != null)
        {
            string strUrlName = RouteData.Values["urlname"].ToString();
            BisSortInfo bisSortInfo = new BisSortInfo();
            DataTable dtSort = bisSortInfo.GetSortInfo(strUrlName);
            if (dtSort != null && dtSort.Rows.Count > 0)
            {
                nSortID = Convert.ToInt32(dtSort.Rows[0]["ID"]);
                eType = (ArticelTypeEnum)Convert.ToInt32(dtSort.Rows[0]["Type"]);
                if (dtSort.Rows[0]["PID"].ToString() != string.Empty)
                {
                    ltlSortName.Text += "<a href=\"/faq/" + dtSort.Rows[0]["PPageUrlName"].ToString() + "/\" title=\"" + dtSort.Rows[0]["PName"].ToString() + "\" target=\"_blank\">" + Server.HtmlEncode(dtSort.Rows[0]["PName"].ToString()) + "</a> &gt; ";
                }
                ltlSortName.Text += "<a href=\"/faq/" + dtSort.Rows[0]["PageUrlName"].ToString() + "/\" title=\"" + dtSort.Rows[0]["Name"].ToString() + "\" target=\"_blank\">" + Server.HtmlEncode(dtSort.Rows[0]["Name"].ToString()) + "</a>";
            }
            else
            {
                Response.Redirect("/404.html");
            }
        }
        else
        {
            Response.Redirect("/404.html");
        }
    }

    protected void InitData()
    {
        if (RouteData.Values["id"] != null)
        {
            BisFeedBack bisFeedBack = new BisFeedBack();

            DataTable dtFaq = bisFeedBack.GetList(Convert.ToInt32(RouteData.Values["id"]));
            if (dtFaq != null && dtFaq.Rows.Count > 0)
            {
                SetPageInfo(dtFaq.Rows[0]["Title"].ToString() + "_" + strWebTitle, string.Empty, string.Empty);
                bisFeedBack.SetTouch(Convert.ToInt32(RouteData.Values["id"]));
                string strPageTitle = string.IsNullOrEmpty(dtFaq.Rows[0]["PageTitle"].ToString()) ? (dtFaq.Rows[0]["Title"].ToString() + "_" + strWebTitle) : dtFaq.Rows[0]["PageTitle"].ToString();
                SetPageInfo(strPageTitle, dtFaq.Rows[0]["PageKeywords"].ToString(),dtFaq.Rows[0]["PageDescription"].ToString());
            }
            rptFaq.DataSource = dtFaq;
            rptFaq.DataBind();

            DataTable dtFaq1 = bisFeedBack.GetTopList(8, 0);
            rptFaq1.DataSource = dtFaq1;
            rptFaq1.DataBind();
            dtFaq1.Dispose();

            DataTable dtFaq2 = bisFeedBack.GetTopList(8, nSortID);
            rptFaq2.DataSource = dtFaq2;
            rptFaq2.DataBind();
            dtFaq2.Dispose();
        }
    }
}